{% extends("common/base.html")%}
{% block title %} 权限管理系统 {% endblock %}
{% block head %}
<style>
    html,
    body {
        background-color: #F1F1F1;
        margin: 0;
        padding: 0;
    }

    .layui-fluid {
        padding: 15px;
    }
</style>
{% endblock %}

{% block body %}
<div class="layui-fluid">
    <div class="layui-card">
        <div class="layui-card-body">
            <form class="layui-form" style="padding-top: 20px;" data-url="{{url_for('role.edit', id=role.id)}}" method="post">
                {{form.csrf_token}}
                <div class="layui-form-item">
                    <label class="layui-form-label"><span style="color: #f00;">*</span> 角色名称：</label>
                    <div class="layui-input-block">
                        <input type="text" name="name" lay-verify="required" lay-reqtext="角色是必填项" autocomplete="off"
                            class="layui-input" placeholder="请输入角色名称" value="{{role.name}}">
                    </div>
                </div>
                <div class="layui-form-item layui-form-text">
                    <label class="layui-form-label">权限菜单：</label>
                    <div class="layui-input-block">
                        <div id="tree"></div>
                    </div>
                </div>
                <div class="layui-form-item">
                    <div class="layui-input-block">
                        <button class="layui-btn layui-btn-normal" lay-submit lay-filter="siteInfo">立即提交</button>
                    </div>
                </div>
            </form>
        </div>
    </div>
</div>
<script>
    layui.config({
        base: '/static/layui/lay/modules/',
    }).extend({
        authtree: 'authtree',
    });
</script>
<script>
    layui.use(['form', 'element', 'authtree'], function () {
        let form = layui.form;
        let authtree = layui.authtree;
        form.render();
        authtree.render('#tree', {{ tree | safe}}, {
        inputname: 'auth[]',
        layfilter: 'lay-check-auth',
        autowidth: true,
        openall: true,
        childKey: 'children',
        theme: 'auth-skin-default',
        themePath: '/static/layui/lay/themes/' // 主题路径，默认 layui_exts/tree_themes/
    });
    //监听信息提交
    form.on('submit(siteInfo)', function (data) {
        doAjaxSubmit($(".layui-form"));
        return false;
    });
    });
</script>
{% endblock %}